/**
 * 
 */
package openbang.account.web.portal.widget;

import java.util.List;

import openbang.account.service.vo.GradeEnum;
import openbang.account.service.vo.UserLoginInfo;

import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * @author aibo zeng
 *
 */
public class ViewSessionList extends Composite {
	VerticalPanel vPanelRoot = new VerticalPanel();
	Grid userGrid = new Grid();
	
	public ViewSessionList() {
		initWidget(vPanelRoot);
		vPanelRoot.add(userGrid);
	}


	public void initData(List<UserLoginInfo> users) {
		userGrid.setStyleName("memberListTable");//这里设置css memberListTable在IE里没有效果
		userGrid.resize(users.size()+1,4);
		userGrid.setHTML(0,0,"<div class=\"memberListTable\"><center><b>帐号</b></center></div>");
		userGrid.setHTML(0,1,"<div class=\"memberListTable\"><center><b>昵称</b></center></div>");
		userGrid.setHTML(0,2,"<div class=\"memberListTable\"><center><b>类型</b></center></div>");
		userGrid.setHTML(0,3,"<div class=\"memberListTable\"><center><b>最近操作日期</b></center></div>");
		int row = 1; //从起始位1开始
		for(UserLoginInfo user : users){
			userGrid.setHTML(row, 0,"<div class=\"memberListTable\">"+ user.getEmail()+"</div>");
			userGrid.setHTML(row, 1,"<div class=\"memberListTable\">"+ user.getNiceName()+"</div>");
			userGrid.setHTML(row, 2,"<div class=\"memberListTable\">"+ GradeEnum.getDesc(user.getGrade())+"</div>");
			userGrid.setHTML(row, 3,"<div class=\"memberListTable\">"+ DateTimeFormat.getFormat("yyyy-MM-dd HH:mm").format(user.getLastAccessDate())+"</div>");
			row++;
		}
	}

}
